package br.com.massai.model;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import br.com.massai.controller.interceptor.LogInterceptor;
import br.com.massai.model.dao.IGenericDao;
import br.com.massai.model.entity.Teste;
import br.com.massai.model.exception.SystemException;

@ManagedBean
@ViewScoped
@SuppressWarnings("all")
public class TesteBean {

	private static final Logger LOG = LogManager.getLogger(LogInterceptor.class.getSimpleName());

	private Teste t = new Teste();

	@EJB IGenericDao iGenericDao;

	@PostConstruct
	public void init(){
		LOG.info("LOGGING...");
		try {
			LOG.info("LOADING...");
			iGenericDao.setEntity(Teste.class);
			LOG.info("SEARCHING...");
			iGenericDao.findExamples(t);

		} catch (SystemException e) {
			LOG.error("ERROR...");
			e.printStackTrace();
		}
		LOG.info("FINALLY!!!");
	}

	public Teste getT() {
		return t;
	}

	public void setT(Teste t) {
		this.t = t;
	}
}